package com.lh.portal.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lh.pojo.Food;
import com.lh.pojo.User;
import com.lh.portal.service.IUserService;


@Controller
public class UserController {
	@Autowired
	IUserService userservice;
	//用户登录，登录后保存uid，uname到session
	@RequestMapping("userlogin")
	public String userLogin(String uname,String upass,HttpServletRequest request) {
		User user = new User();
		user.setUname(uname);
		user.setUpass(upass);
		User myuser = userservice.selUserTologin(user);
		HttpSession session = request.getSession();
		if(myuser != null) {
			session.setAttribute("uid", myuser.getUid());
			session.setAttribute("uname", myuser.getUname());
			return "findall";
		}else {
			request.setAttribute("msg", "用户名或密码错误");
			return "/login.jsp";
		}
	}
	//查询菜单到主页面
	@RequestMapping("findall")
	public String findAllFood() {
		return null;
		
	}
}
